package com.sjq.config;

import com.sjq.model.common.ConstantImg;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
/**
 * @author: sjq
 * @create: 2021-12-05
 **/

@Configuration
public class WebConfig extends WebMvcConfigurationSupport {

    /**
     * 大坑，必须重写此方法，不然swagger页面打不开
     */
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/**").addResourceLocations(
                "classpath:/static/");
        registry.addResourceHandler("swagger-ui.html").addResourceLocations(
                "classpath:/META-INF/resources/");
        registry.addResourceHandler("/webjars/**").addResourceLocations(
                "classpath:/META-INF/resources/webjars/");
        registry.addResourceHandler("/static/**").addResourceLocations("classpath:/static/");
        registry.addResourceHandler("/imgs/**").addResourceLocations("file:"+ ConstantImg.Upload_File_Dir);
        super.addResourceHandlers(registry);
    }
}


